import React from 'react'
// 写嵌套路由
import { Routes, Route, Navigate } from 'react-router-dom'
import Car1 from './Car1'
import Car2 from './Car2'
type Props = {}

export default function Car({ }: Props) {
    return (
        <div>
            <p>Car页面</p>
            {/*
             嵌套的路由组件 
             注意: 二级路由的path 两种写法 ,但是不能拼接一级的path
                写法1:  path = '/二级path'
                写法2:  path = '二级path' 
            */}
            <Routes>
                {/*设置 默认匹配二级组件 */}
                {/* <Route path='' element={<Car1></Car1>}></Route> */}
                <Route path='car1' element={<Car1></Car1>}></Route>
                <Route path='car2' element={<Car2></Car2>}></Route>
                {/* 使用路由重定向设置默认显示的二级组件*/}
                <Route path='' element={<Navigate to='car1'></Navigate>}></Route>
            </Routes>
        </div>
    )
}